package com.example.shardingspheredemo.model.t.controller;

import com.example.shardingspheredemo.model.t.entity.ClassEntity;
import com.example.shardingspheredemo.model.t.service.ClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Timestamp;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * @author Andrew Yang
 * @className ClassController
 * @description
 * @package com.example.shardingspheredemo.model.t.controller
 * @create 2020-09-15 17:27
 */
@RestController
@RequestMapping("/class")
public class ClassController {
    @Autowired
    private ClassService classService;

    /**
     * @Description: 批量保存用户
     */
    @PostMapping("save-class")
    public Object saveClass() {
        List<ClassEntity> classEntities = Arrays.asList(
                new ClassEntity("数学课1", new Timestamp(new Date().getTime())),
                new ClassEntity("数学课2", new Timestamp(new Date().getTime())),
                new ClassEntity("数学课3", new Timestamp(new Date().getTime())),
                new ClassEntity("数学课4", new Timestamp(new Date().getTime())),
                new ClassEntity("数学课5", new Timestamp(new Date().getTime())),
                new ClassEntity("数学课6", new Timestamp(new Date().getTime())),
                new ClassEntity("数学课7", new Timestamp(new Date().getTime())),
                new ClassEntity("数学课8", new Timestamp(new Date().getTime())),
                new ClassEntity("数学课9", new Timestamp(new Date().getTime())),
                new ClassEntity("数学课10", new Timestamp(new Date().getTime())),
                new ClassEntity("数学课11", new Timestamp(new Date().getTime())),
                new ClassEntity("数学课12", new Timestamp(new Date().getTime())),
                new ClassEntity("数学课13", new Timestamp(new Date().getTime())),
                new ClassEntity("数学课14", new Timestamp(new Date().getTime())),
                new ClassEntity("数学课15", new Timestamp(new Date().getTime())),
                new ClassEntity("数学课16", new Timestamp(new Date().getTime())),
                new ClassEntity("数学课17", new Timestamp(new Date().getTime())),
                new ClassEntity("数学课18", new Timestamp(new Date().getTime())),
                new ClassEntity("数学课19", new Timestamp(new Date().getTime())),
                new ClassEntity("数学课20", new Timestamp(new Date().getTime()))
        );
        return classService.insertForeach(classEntities);
    }
}
